var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (i, t) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, i) {
              e.__proto__ = i;
            }) ||
          function (e, i) {
            for (var t in i)
              Object.prototype.hasOwnProperty.call(i, t) && (e[t] = i[t]);
          })(i, t);
      };
      return function (i, t) {
        function n() {
          this.constructor = i;
        }
        if ("function" != typeof t && null !== t)
          throw new TypeError(
            "Class extends value " + String(t) + " is not a constructor or null"
          );
        e(i, t),
          (i.prototype =
            null === t
              ? Object.create(t)
              : ((n.prototype = t.prototype), new n()));
      };
    })(),
  FriendsDetailDialog = (function (e) {
    function i() {
      var i = e.call(this) || this;
      return (
        (i.onLoadTianJiaPersonData = {
          caller: i,
          code: 1024,
          method: function (e) {
            0 == e.code
              ? ToastView.toastView(e.data)
              : ToastView.toastView(e.msg),
              i.close();
          },
        }),
        (i.onLoadShanChuPersonData = {
          caller: i,
          code: 1038,
          method: function (e) {
            0 == e.code
              ? (ToastView.toastView(e.data),
                WebSocketService.send({ c: 1160, d: { pageNum: 0 } }))
              : ToastView.toastView(e.msg),
              i.close();
          },
        }),
        (i.onLoadOtherPersonData = {
          caller: i,
          code: 1020,
          method: function (e) {
            if (0 == e.code) {
              var t = e.data;
              (i.friendObj = e.data),
                (i.lable_friends_title.text = e.data.name + " - " + e.data.id),
                e.data.vip && e.data.vip > 0
                  ? (i.label_vip_level.text = "VIP " + e.data.vip)
                  : (i.label_vip_level.text = "非VIP"),
                i.dealOnlineState(t.online),
                (i.list_friends_descr.visible = !0);
              var n = e.data.roleType + "" + e.data.sex,
                o = Dictionary.wsImgname[n];
              i.image_friend_headicon.skin = "comp/hreoImg/" + o + ".png";
              var a = [],
                d = Utils.dealRole_Type(t.roleType),
                r = Utils.dealTransAndLvl(t.roleType, t.lvl),
                l = r + d;
              t.title && "无" != t.title && (l = r + "  -  " + t.title),
                a.push(l),
                a.push("攻击：" + t.ap),
                a.push("防御：" + t.df),
                a.push("气血：" + t.hp + "/" + t.maxHp),
                a.push("精力：" + t.mp + "/" + t.maxMp),
                a.push(""),
                a.push("活力值：" + t.hyd),
                a.push("教派：" + t.religion.name),
                a.push("房产：" + t.house.name),
                t.horse && a.push("坐骑：" + t.horse.name);
              var s = "";
              if (t.cortegeList.length > 0) {
                for (_ = 0; _ < t.cortegeList.length; _++) {
                  s = s + t.cortegeList[_].name + "  ";
                }
                a.push("副将：" + s);
              }
              a.push(""),
                a.push("关系：" + t.relation),
                a.push("友好度：" + t.friendNum),
                a.push("魅力值：" + i.dealMeiLiZhiState(t.charm)),
                a.push("配偶：" + t.spouse.name),
                a.push("师傅：" + t.spouse.name),
                (i.btn_friend_operate.visible = !0);
              var c = void 0;
              1 == t.friend
                ? ((c = "断交"),
                  t.remark
                    ? (i.label_beizhu_name.text = t.remark)
                    : (i.label_beizhu_name.text = "添加备注"),
                  (i.btn_add_beizhu.visible = !0))
                : 0 == t.friend
                ? ((c = "添加好友"), (i.btn_add_beizhu.visible = !1))
                : ((i.btn_friend_operate.visible = !1),
                  (i.btn_add_beizhu.visible = !1)),
                console.log(t.black),
                t.black,
                t.id == Global.roleId
                  ? ((i.btn_privateChatMsg.visible = !1),
                    (i.btn_friend_sendEmail.visible = !1),
                    (i.btn_friends_qiecuo.visible = !1))
                  : ((i.btn_privateChatMsg.visible = !0),
                    (i.btn_friend_sendEmail.visible = !0),
                    (i.btn_friends_qiecuo.visible = !0),
                    a.push("0")),
                (i.btn_friend_operate.label = c);
              for (var h = void 0, b = [], _ = 0; _ < a.length; _++) {
                var u = a[_];
                (h = { label_friend_name: { text: u }, black: u }), b.push(h);
              }
              i.list_friends_descr.dataSource = b;
            } else ToastView.toastView(e.msg);
          },
        }),
        (i.onLoadSearchFriendDataFn = {
          caller: i,
          code: 1165,
          method: function (e) {
            0 == e.code &&
              e.list.length <= 0 &&
              (i.close(), ToastView.toastView("未查到此人"));
          },
        }),
        (i.onLoadJieChuLaHeiData = {
          caller: i,
          code: 1026,
          method: function (e) {
            0 == e.code &&
              WebSocketService.send({ c: 1020, d: { userId: i.friendObj.id } });
          },
        }),
        (i.onLoadHaoYouBeiZhuMessageFn = {
          caller: i,
          code: 1167,
          method: function (e) {
            WebSocketService.send({ c: 1160, d: { pageNum: 0 } });
          },
        }),
        i.btn_friendDetail_close.on(
          Laya.Event.CLICK,
          i,
          i.onCloseFriendDetailFn
        ),
        i.btn_privateChatMsg.on(
          Laya.Event.CLICK,
          i,
          i.onDidClickPricateChatMsgFn
        ),
        i.btn_friend_operate.on(
          Laya.Event.CLICK,
          i,
          i.onDidClickFriendOperateFn
        ),
        i.btn_friends_qiecuo.on(Laya.Event.CLICK, i, i.onDidClickQieCuoAction),
        i.btn_friends_tanwei.on(Laya.Event.CLICK, i, i.onDidClickTanWeiAction),
        i.btn_friend_zhuangbei.on(
          Laya.Event.CLICK,
          i,
          i.onDidClickZhuangBeiAction
        ),
        WebSocketService.addListener(i.onLoadJieChuLaHeiData, !0),
        WebSocketService.addListener(i.onLoadHaoYouBeiZhuMessageFn, !0),
        WebSocketService.addListener(i.onLoadSearchFriendDataFn, !0),
        WebSocketService.addListener(i.onLoadOtherPersonData, !0),
        WebSocketService.addListener(i.onLoadOtherPersonData, !0),
        WebSocketService.addListener(i.onLoadTianJiaPersonData, !0),
        WebSocketService.addListener(i.onLoadShanChuPersonData, !0),
        (i.list_friends_descr.vScrollBarSkin = ""),
        (i.list_friends_descr.renderHandler = new Handler(
          i,
          i.onUpdateRenderHandler
        )),
        (i.list_friends_descr.selectEnable = !0),
        i.list_friends_descr.on(Laya.Event.CLICK, i, i.onDidListFriAction),
        i.btn_add_beizhu.on(
          Laya.Event.CLICK,
          i,
          i.onDidClickModifyBeiZhuAction
        ),
        i.btn_friend_sendEmail.on(
          Laya.Event.CLICK,
          i,
          i.onFriendSendEmailDidClick
        ),
        i
      );
    }
    return (
      __extends(i, e),
      (i.prototype.init = function () {
        (this.list_friends_descr.dataSource = []),
          (this.lable_friends_title.text = ""),
          (this.text_add_beizhu.visible = !1),
          (this.btn_add_beizhu.label = "修改"),
          (this.btn_privateChatMsg.visible = !1),
          (this.btn_friend_sendEmail.visible = !1),
          (this.btn_friends_qiecuo.visible = !1);
      }),
      (i.showFriendDialog = function (e, t) {
        null == this.friendDialog &&
          ((this.friendDialog = new i()), (this.friendDialog.zOrder = 1e3)),
          this.friendDialog.popup(!0),
          this.friendDialog.init(),
          (this.friendDialog.label_beizhu_name.text = ""),
          1 == t
            ? WebSocketService.send({ c: 1020, d: { userId: e } })
            : WebSocketService.send({ c: 1165, d: { s: e, pageNum: 0 } });
      }),
      (i.prototype.onDidClickFriendOperateFn = function (e) {
        if ("断交" == e.target.label) {
          var i = "您确认要断交与 " + this.friendObj.name + " 的好友关系吗？";
          NormalDialog.showNormalDialog(i, this, this.okDeleteMethodFuntion);
        } else
          "添加好友" == e.target.label &&
            WebSocketService.send({
              c: 1024,
              d: { roleid: this.friendObj.id },
            });
      }),
      (i.prototype.okDeleteMethodFuntion = function () {
        WebSocketService.send({ c: 1038, d: { roleid: this.friendObj.id } });
      }),
      (i.prototype.onDidClickFriendsLaHeiFn = function (e) {
        var i = "0";
        "拉黑" == e.target.label
          ? (i = "0")
          : "解除拉黑" == e.target.label && (i = "1"),
          WebSocketService.send({
            c: 1026,
            d: { id: this.friendObj.id, t: i },
          });
      }),
      (i.prototype.onUpdateRenderHandler = function (e, i) {
        var t = e.getChildByName("btn_friend_lahei");
        i == this.list_friends_descr.dataSource.length - 1 &&
        this.friendObj.id != Global.roleId
          ? ((t.visible = !0),
            "0" == this.friendObj.black
              ? (t.label = "拉黑")
              : (t.label = "解除拉黑"))
          : (t.visible = !1);
      }),
      (i.prototype.onDidListFriAction = function (e) {
        if ("" != e.target.name && "btn_friend_lahei" == e.target.name) {
          var i = "0";
          (i = "0" == this.friendObj.black ? "0" : "1"),
            WebSocketService.send({
              c: 1026,
              d: { id: this.friendObj.id, t: i },
            });
        }
      }),
      (i.prototype.dealFriends = function (e) {
        return "1" == e ? "好友" : "-1" == e ? "自己" : "不是好友";
      }),
      (i.prototype.dealOnlineState = function (e) {
        "在线" == e
          ? ((this.label_friend_online.text = "在线"),
            (this.label_friend_online.color = "#08f41b"))
          : ((this.label_friend_online.text = e),
            (this.label_friend_online.color = "#dddddd"));
      }),
      (i.prototype.dealMeiLiZhiState = function (e) {
        return "-1" == e ? "无" : e;
      }),
      (i.prototype.onDidClickPricateChatMsgFn = function () {
        PrivateChatDialog.showPrivateMsgDialog(this.friendObj);
      }),
      (i.prototype.onDidClickModifyBeiZhuAction = function (e) {
        if (((this.text_add_beizhu.visible = !0), "修改" == e.target.label))
          this.btn_add_beizhu.label = "确定";
        else if ("确定" == e.target.label) {
          if (this.text_add_beizhu.text.length <= 0) return;
          WebSocketService.send({
            c: 1167,
            d: { id: this.friendObj.id, s: this.text_add_beizhu.text },
          }),
            (this.btn_add_beizhu.label = "修改"),
            (this.text_add_beizhu.visible = !1),
            (this.label_beizhu_name.text =
              "备注：" + this.text_add_beizhu.text);
        }
      }),
      (i.prototype.onFriendSendEmailDidClick = function () {
        this.close(), SendEmailEditView.openSendEmailView(this.friendObj.id);
      }),
      (i.prototype.onDidClickQieCuoAction = function () {
        Fight.WaitFight.open(this.friendObj.id, this.friendObj.name);
      }),
      (i.prototype.onCloseFriendDetailFn = function () {
        this.close();
      }),
      (i.prototype.onDidClickTanWeiAction = function () {
        this.close();
        var e = this.friendObj.id,
          i = AXFlyMyMarketView.openModifyView("other", e);
        i.pos(0, 35), Laya.stage.addChild(i);
      }),
      (i.prototype.onDidClickZhuangBeiAction = function () {
        var e = {
          id: this.friendObj.id,
          name: this.friendObj.name,
          roleType: this.friendObj.roleType,
          sex: this.friendObj.sex,
        };
        FriendEqumentDialog.showFriendsEqumentDialog(e);
      }),
      (i.close = function () {
        this.friendDialog &&
          ((this.friendDialog.text_add_beizhu.visible = !1),
          this.friendDialog.close(),
          (this.friendDialog = null));
      }),
      i
    );
  })(ui.FriendMomentController.FriendsDetailDialogUI);
